package com.bw.controller;

import com.bw.domain.Car;
import com.bw.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CarController {
    @Autowired
    CarService carService;

    @RequestMapping("/list")
    public List t1(String name,String carno){
        List<Car> list = carService.getCarList(name,carno);
        for (Car car : list) {
            System.out.println(car);
        }
        return list;
    }

    @RequestMapping("/add")
    public Integer t2(Car car){
        Integer i = carService.addCar(car);
        return i;
    }

    @RequestMapping("/del")
    public Integer t3(Integer[] arr){
        Integer i = carService.delCar(arr);
        return i;
    }

    @RequestMapping("/update")
    public Integer t4(String name,Integer id){
        Integer i = carService.updateCar(name,id);
        return i;
    }
}
